option(KLAYGE_BUILD_TESTS "Build tests" ON)
if(NOT KLAYGE_BUILD_TESTS)
	return()
endif()

DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/leaf_v3_green_tex.dds" "c180e28392be0f6d9b8e429c416392923d9e7139")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/leaf_v3_green_tex_bc2.dds" "3e4095b5252662319898cabd4011f0d9d50faad8")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/leaf_v3_green_tex_bc3.dds" "f596c895a2248b7650486adf32b911b5380c6f04")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/leaf_v3_green_tex_bc7.dds" "7c55686ca97660ca3c057437e37c596c5455449b")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/Lenna.dds" "292f31bcc45712989e1f3593835d5129bba8c0ac")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/Lenna_bc1.dds" "1c236d9d06364fbeb03a274802b086d782a9609b")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/Lenna_bc7.dds" "90a50b2ed010a9d29ebf36d7c2dd5f93ed1d44c0")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/memorial.dds" "cee51491891a16bf5cc39eb1fd54fff0b0ae0683")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/memorial_bc6u.dds" "23609a1794f2c95b643c12282728a9865988fc47")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/uffizi_probe.dds" "f614b2494da0b649e0c14a2648213a3c95da8bcc")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/EncodeDecodeTex/uffizi_probe_bc6s.dds" "f3b28807c56a1c8b99d1fe8d831d6a653539abd1")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/anim.fbx" "529AD0044C9F4EA1296384F0CC9BD28061E1742D")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/anim.glb" "9CC4480521136D2AA938FD70621AF58FCBFE587F")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.lod.meshml" "4212E01180D2D6B3EB7B69C1AAF197C1332BED8B")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.lod_autocenter.meshml" "43C2FEED0019A3518BF5E7B7BFF8E9DFDCA2B09A")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.lod_axismapping.meshml" "16676D7CC4199C658CF9C6D913F6F6A5DBB1DD95")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.lod_trans.meshml" "8736FD5BF7F90627108B04D09A3A5582FEA675E9")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.mtl" "069F32D2540B9A001AC39D9A7259EDB5A3CF815C")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a.nolod.meshml" "1908F8A17E988A55454310A5D8B7F11DD4CB3966")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a_lod0.obj" "CCAD8B5BB3767CCE0EB391DF67DA3E38C5294268")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a_lod1.obj" "BCCF4CFFD13FB303EB5D4E23CEBEF1EB795E87FF")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/MeshConverter/tree2a_lod2.obj" "F4C65CAC3FB26EF3CF4E248F5E99C3DA2E1E5F44")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/RenderToTexture/RenderToTextureMS2Test.dds" "942271432b537910e7641ed54127c089013ec8ce")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/RenderToTexture/RenderToTextureMS4Test.dds" "c88665cb9bd306e0f56b2bae7211fd37526a31e4")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/RenderToTexture/RenderToTextureMS8Test.dds" "ab7ebba0eca47348e7daa0d1fac01b4ccd10d677")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/RenderToTexture/RenderToTextureTest.dds" "1a0f45e5edf0c52932f7b47893d6a292e11346e2")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/ResLoader/Test.7z" "f128c4a3861d69279b2b43c885bf107b2dd4aaf0")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/ResLoader/TestPassword.7z" "3b300e251ec5181ba03b24e57e478cab9d347471")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/array.dds" "C66B407817D0A08FBBE604F8616A6BB6991F1E50")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/array_mip.dds" "4B9714B72BAF80356DB3F373D5E71BCAED63E911")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background.jpg" "8981B88F6D7DC9803AEFD3B5D385648A854B2BF9")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_half.jpg" "4E380212E73BCC458A6C0C7E258931BDFD317312")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_lum.dds" "C4DEE3ED5735E39BE7ED83C403B879802B10FD6C")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_normal.dds" "016CC35F3A9C31FD826454477E0EC7C446EECA79")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_normal_0_4.dds" "13A2EF31CE6A73A2187066C80A02E3F750A6DAF4")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_occlusion.dds" "4080971110111DCC90D6F9926170E0EB672E7BDD")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_occlusion_0_6.dds" "1DC5EA232F2AE2C519D40EE64441D31C21AAC308")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/background_quarter.jpg" "62788E090ED34778B580546BF63B46DFD71F5A03")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_bc1.dds" "342CF223D7321377050637FCCD776BF35F4DD349")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_bc1_channel.dds" "98F7091D47865656DFC5BE455128AD6CBDF1D188")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_bc1_srgb.dds" "69FB4F3974A43126B209E449FAA7B2E8060874D8")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_bc7_srgb.dds" "E9B104B512FF7B548D30CFBEA54A58A0B10665B1")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_channel.dds" "686A9D79033E7E2CFD9EA763D539C5847E2B80BF")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion.jpg" "CAF917254D3928CE05158548724AE711025E81E4")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_mip.dds" "5ABC1C2BE25F92025C22254DCDBDC2E01DAA8CDA")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_passthrough.dds" "D27BDC046448B35CCCAC8D763599B2C80329410A")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn.jpg" "7CC2143C4AACC41E4606E5DECC9E728DFEF16E6E")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn_bc3.dds" "712056F05E761E00AE8DAB292C0C76490766CED8")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn_bc5.dds" "EFC089D464460047A21F31F2A3D33041BEDE668D")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn_gr.dds" "681FF21203981D0CA14DE2C03713A59EFD0D08A0")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn_half.jpg" "9747A53EE30257E612F8697495ABC88F2D9B543C")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_ddn_quarter.jpg" "23F8715F35F2234E62CCED056C1A8455D5B3BB9A")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_half.jpg" "F60D54299486F6B62000761EB44DC088F7D375D5")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_height.dds" "D3F0556E8D284757F5DD616175D19E434901D896")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/TexConverter/lion_quarter.jpg" "E73C4DF3CE43199B54DB90E6CB126256879F55C6")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/Texture/Lenna_quarter.dds" "A6CB01CBA1FB5BBE5BC6FA877296F37A21BFED55")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/Texture/Lenna_quarter_bc1.dds" "F0BB74E26AEAA2D5C5CED3E5542D03B74D58E19D")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/Texture/Lenna_SubTexture.dds" "00752700F28F60908921B230D35D7B2AA1F077E3")
DOWNLOAD_DEPENDENCY("KlayGE/Tests/media/Texture/Lenna_SubTexture_bc1.dds" "149805BA037B01DCFB20260C6EA9C982C17C16BD")

SET(SOURCE_FILES
	${KLAYGE_PROJECT_DIR}/Tests/src/BlitterTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/CTHashTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/EncodeDecodeTexTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/KlayGETests.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/MathTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/MeshConverterTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/MipmapperTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/RenderToTextureTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/ResLoaderTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/SIMDMathTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/StreamOutputTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/StringUtilTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/TexConverterTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/TextureTest.cpp
	${KLAYGE_PROJECT_DIR}/Tests/src/UavOutputTest.cpp
)
SET(HEADER_FILES
	${KLAYGE_PROJECT_DIR}/Tests/src/KlayGETests.hpp
)
if(KLAYGE_PLATFORM_WINDOWS_DESKTOP)
	set(RESOURCE_FILES $<TARGET_OBJECTS:KlayGE_RC>)
else()
	set(RESOURCE_FILES "")
endif()
SET(EFFECT_FILES
	${KLAYGE_PROJECT_DIR}/Tests/media/RenderToTexture/RenderToTextureTest.fxml
	${KLAYGE_PROJECT_DIR}/Tests/media/StreamOutput/StreamOutputTest.fxml
	${KLAYGE_PROJECT_DIR}/Tests/media/UavOutput/UavOutputTest.fxml
)
SET(POST_PROCESSORS "")
SET(UI_FILES "")

SOURCE_GROUP("Source Files" FILES ${SOURCE_FILES})
SOURCE_GROUP("Header Files" FILES ${HEADER_FILES})
SOURCE_GROUP("Resource Files" FILES ${RESOURCE_FILES})
SOURCE_GROUP("Effect Files" FILES ${EFFECT_FILES})
SOURCE_GROUP("Post Processors" FILES ${POST_PROCESSORS})
SOURCE_GROUP("UI Files" FILES ${UI_FILES})

ADD_EXECUTABLE(Tests "" ${SOURCE_FILES} ${HEADER_FILES} ${RESOURCE_FILES} ${EFFECT_FILES} ${POST_PROCESSORS} ${UI_FILES})

target_include_directories(Tests
	PRIVATE
		${KLAYGE_PROJECT_DIR}/Plugins/Include
)

SET_TARGET_PROPERTIES(Tests PROPERTIES
	DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
	CXX_VISIBILITY_PRESET hidden
	VISIBILITY_INLINES_HIDDEN ON
	OUTPUT_NAME Tests${KLAYGE_OUTPUT_SUFFIX}
	FOLDER "KlayGE/Tests"
)

ADD_DEPENDENCIES(Tests AllInEngine)

target_link_libraries(Tests
	PRIVATE
		KlayGE_DevHelper
		KlayGE_Core
		gtest
)

CREATE_PROJECT_USERFILE(KlayGE Tests)
